//
//  LTFContentTableViewCell.m
//  NeteaseNews
//
//  Created by liutaifeng on 16/4/19.
//  Copyright © 2016年 liutaifeng. All rights reserved.
//

#import "LTFContentTableViewCell.h"
#import "IsNight.h"
#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
@implementation LTFContentTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
        //背景
    self.backView = [[UIView alloc] init];
    //_backView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_backView];
    [_backView release];
    
    
    //标题
    self.title = [[UILabel alloc] init];
    //_title.backgroundColor = [UIColor blueColor];
    [self.backView addSubview:_title];
    [_title release];
    
    //图片
    self.picImageView = [[UIImageView alloc] init];
    //_picImageView.backgroundColor = [UIColor whiteColor];
    [self.backView addSubview:_picImageView];
    [_picImageView release];
    
    //播放按钮
    self.playButton = [[UIImageView alloc] init];
    //self.playButton.backgroundColor = [UIColor blackColor];
    [self.backView addSubview:_playButton];
    
    
    self.timeAndCountLabel = [[UILabel alloc] init];
    [self.backView addSubview:_timeAndCountLabel];
    //_timeAndCountLabel.backgroundColor = [UIColor blackColor];
    [_timeAndCountLabel release];
    _timeAndCountLabel.textColor = [UIColor whiteColor];
    
    
    //头像和名字背景
    self.headView = [[UIView alloc] init];
    [self.backView addSubview:_headView];
    //_headView.backgroundColor = [UIColor grayColor];
    [_headView release];
    
    //头像
    self.headImageView = [[UIImageView alloc] init];
    [self.backView addSubview:_headImageView];
    //_headImageView.backgroundColor = [UIColor blackColor];
    [_headImageView release];
    //名字
    self.nameLabel = [[UILabel alloc] init];
    [self.backView addSubview:_nameLabel];
    //_nameLabel.backgroundColor = [UIColor redColor];
    [_nameLabel release];
    
    
    //回复按钮
    self.replyButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.backView addSubview:_replyButton];
    //_replyButton.backgroundColor = [UIColor blackColor];
    
    //回复数
    self.replyLabel = [[UILabel alloc] init];
    [self.backView addSubview:_replyLabel];
    //_replyLabel.backgroundColor = [UIColor blackColor];
    [_replyLabel release];
    //分享按钮
    self.shareButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.backView addSubview:_shareButton];
    //_shareButton.backgroundColor = [UIColor greenColor];
    
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    if ([IsNight nowIsNight]) {
        self.contentView.backgroundColor = [IsNight nightColor];
        _backView.backgroundColor = [IsNight nightColor];
        _title.textColor = [IsNight textNightColor];
        _timeAndCountLabel.textColor = [UIColor whiteColor];
        _nameLabel.textColor = [IsNight textNightColor];
        _replyLabel.textColor = [IsNight textNightColor];
    }
    else {
        self.contentView.backgroundColor = [UIColor whiteColor];
        _backView.backgroundColor = [UIColor whiteColor];
        _title.textColor = [UIColor blackColor];
        _timeAndCountLabel.textColor = [UIColor blackColor];
        _nameLabel.textColor = [UIColor blackColor];
        _replyLabel.textColor = [UIColor blackColor];
    }


    self.backView.frame = CGRectMake(10, 10, WIDTH - 20, HEIGHT - 20);
    self.backView.layer.borderWidth = 1;
    self.backView.layer.cornerRadius = 5;
    self.title.frame = CGRectMake(10, 10, WIDTH / 4 * 3, 30);
    self.picImageView.frame = CGRectMake(2, 50, WIDTH - 24, HEIGHT / 2 + 30);
    self.headView.frame = CGRectMake(15, HEIGHT / 2 + 90, WIDTH / 3 + 10, 30);
    self.headView.layer.cornerRadius = 15;
    self.headImageView.frame = CGRectMake(15, HEIGHT / 2 + 90, 30, 30);
    self.headImageView.layer.cornerRadius = 15;
    self.headImageView.layer.masksToBounds = YES;
    self.nameLabel.frame = CGRectMake(50, HEIGHT / 2 + 90, WIDTH / 3 - 20, 30);
    self.replyButton.frame = CGRectMake(WIDTH / 4 * 3 - 70, HEIGHT / 2 + 90, 30, 30);
    [self.replyButton setImage:[UIImage imageNamed:@"回复.png"] forState:UIControlStateNormal];
    
    
    self.replyLabel.frame = CGRectMake(WIDTH / 4 * 3 - 40, HEIGHT / 2 + 90, 50, 30);
    self.shareButton.frame = CGRectMake(WIDTH / 4 * 3 + 20, HEIGHT / 2 + 90, 30, 30);
    
    [self.shareButton setImage:[UIImage imageNamed:@"分享.png"] forState:UIControlStateNormal];
    
    self.playButton.frame = CGRectMake(20, 20, 70, 70);
    self.playButton.center = self.picImageView.center;
    self.playButton.layer.cornerRadius = 35;
    self.playButton.image =[UIImage imageNamed:@"bofang.png"];
    self.timeAndCountLabel.frame = CGRectMake(WIDTH / 4 * 3 - 55, HEIGHT / 4 * 3 - 40, WIDTH / 3 - 10, 30);
    
    self.timeAndCountLabel.font = [UIFont systemFontOfSize:13];
    
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
